package com.shouer.doc.widget;

import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by ZXL on 2016/11/18.
 */

public class HorItemDecoration extends RecyclerView.ItemDecoration {

    private int space;
    private boolean hasTop = true;

    public HorItemDecoration(int space) {
        this.space = space;
        hasTop = true;
    }

    public HorItemDecoration(int space, boolean hasTop) {
        this.space = space;
        this.hasTop = hasTop;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view,
                               RecyclerView parent, RecyclerView.State state) {

        if (parent.getChildLayoutPosition(view) == 0 && hasTop) {
            outRect.left = space;
        }

        outRect.right = space;
    }
}
